#ifndef FAVORITESEDIT_H
#define FAVORITESEDIT_H

#include "quicklaunch/quicklaunch.h"
#include "ui_favoritesedit.h"
#include <QtGui/QMainWindow>
#include <QDesktopServices>
#include <QMessageBox>
#include <QSettings>
#include <QProcess>
#include <QUrl>

class FavoritesEdit : public QMainWindow
{
    Q_OBJECT

    public:
        FavoritesEdit(QWidget *parent = 0);
        Ui::FavoritesEdit *favEdit;
        ~FavoritesEdit();

        //Function for the Quick Launch window so changes adjusted will carrythrough to Quick Launch
        void setQuickPointer(QuickLaunch *quick);

        //FavoritesEdit save settings
        void writeFavoritesEditSettings();

        //Selecting existingFavorite Item
        QString existingFavoriteName;
        QString existingFavoritePath;

        //References if the user selecting a website favorite or not
        bool website;

        //Used for determining what the current favorite item is
        QString currentImageName;

        //Needed to select the image from the appropriate folder
        int columnNumber;

        //Used to reference to LifeSync.cpp in order to change the Quick Launch favorites depending on what current favorite was changed in Fav Edit
        int currentFavoriteSelected;

    private:
        //Pointer to the Quick Launch window so changes adjusted will carrythrough to Quick Launch
        QuickLaunch *setQuickLaunch;

        //Ensures the user has selected a current favorite and either an existing or custom favorite before the apply button is activated
        void activateApplyChangesButton();

        //FavoritesEdit load settings
        void readFavoritesEditSettings();

        //New user-custom favorites table item icon
        QIcon icon;

        //Set up to determine if the user is applying a new or existing favorite
        bool existingSelected;

        //Test launch existingFavorite Item
        QString program;
        QStringList arguments;

        //Used to test if the user set both a current and existing item or a new and current item to change, if so enable the apply button
        bool existingFavoriteSet;
        bool currentFavoriteSet;
        bool newFavoriteSet;

        //If current favorite is clicked to be changed then set the appropriate image next to the change to label
        void setCurrentFavoriteForChange();

        //Set up all existing favorite application paths
        QString firefox;
        QString ie;
        QString aim;
        QString msn;
        QString pidgin;
        QString skype;
        QString vlc;
        QString wmp;
        QString itunes;
        QString quicktime;
        QString word;
        QString powerpoint;
        QString excel;

        //Set up to save the user's custom table items
        int newCustomCount;
        int newRow;
        int newColumn;
        QString fileOpen;
        QString fileAppOpen;
        QString newFavPathOne;
        QString newFavPathTwo;
        QString newFavPathThree;
        QString newFavPathFour;
        QString newFavIconOne;
        QString newFavIconTwo;
        QString newFavIconThree;
        QString newFavIconFour;
        QString newFavIconSave;
        QString newFavPathSave;
        bool newFavWebsiteCheckSave;
        bool websiteFavOne;
        bool websiteFavTwo;
        bool websiteFavThree;
        bool websiteFavFour;

    private slots:
        void on_newEdit_Button_clicked();
        void on_newUse_Button_clicked();
        void on_newIcon_Button_clicked();
        void on_newSave_Button_clicked();
        void on_newTest_Button_clicked();
        void on_newApplicationPath_Button_clicked();
        void on_newWebsitePath_Button_clicked();
        void on_changeFavoriteReset_Button_clicked();
        void on_currentFavoriteOne_Button_clicked();
        void on_currentFavoriteTwo_Button_clicked();
        void on_currentFavoriteThree_Button_clicked();
        void on_currentFavoriteFour_Button_clicked();
        void on_currentFavoriteFive_Button_clicked();
        void on_currentFavoriteSix_Button_clicked();
        void on_closeFavoritesEdit_Button_clicked();

        void testNewFavorite();
        void useExistingFavoriteSelected(int, int);
        void setExistingFavorite_LineEdit();
        void testExistingPath();
        void setNewFavoriteForChange();
        void applyNewFavoriteChanges();
        void editExistingFavorite();
        void testEditedExistingPath();
        void saveEditedExistingPath();
        void setExistingDefaultButtons();
        void useNewFavoriteSelected(int, int);
};

#endif // FAVORITESEDIT_H
